package com.mall.web.control.eshop;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mall.biz.user.UserBizImpl;
import com.mall.pojo.User;
import com.mall.vo.user.UserVO;
import com.mall.web.annotation.EShopUserSecurity;
import com.mall.web.util.AliBaiChuanUtil;
import com.mall.web.util.WebUtil;

import UserConstant.EShopUserConstant;

@Controller
@RequestMapping("/eshop/chat/")
public class EShopChatController {
	@Autowired
	private UserBizImpl userBizImpl;

	@RequestMapping("eshopchat")
	@EShopUserSecurity
	public String eshopchat(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		User user = WebUtil.getCurrentUser(request);
		if (user != null) {
			UserVO userVO = this.userBizImpl.getUserVOByUserId(user.getId());
			if (userVO.getUserExtended() != null) {
				String aliTongxueId = userVO.getUserExtended().getAliTongxueId();
				modelMap.put(AliBaiChuanUtil.URL_KEY_HIDDEN_FROMALIBAICHUAN, aliTongxueId);
				modelMap.put(AliBaiChuanUtil.URL_KEY_HIDDEN_TOALIBAICHUAN, EShopUserConstant.ALIBAICHUAN_KEFU_UID);
				modelMap.put(AliBaiChuanUtil.URL_KEY_HIDDEN_TOALIBAICHUANNAME, EShopUserConstant.ALIBAICHUAN_KEFU_NAME);
				modelMap.put(AliBaiChuanUtil.URL_KEY_HIDDEN_ALIBAICHUANPASSWORD, AliBaiChuanUtil.PASS);
			}
		}
		return "eshop/eshopchat";
	}
}
